package cn.com.dstz.agent.config;

import java.util.Map;

public class MemberConfig extends AgentConfig{
	
	public MemberConfig( Map< String, Object > admin, int count ){
		super( admin, count, AgentConfig.CONFIG_USER );
	}

	@Override
	public String getSQL( ) {
		
		if( this.getReturnValue( ).equals( SELF )){
			valueMap.put( "aid", admin.get( "id" ) );
			return " and m.adminid =:aid ";
		}else if( this.getReturnValue( ).equals( ALL ) ){
			valueMap.put( "topaid", admin.get( "topaid" ) );
			return " and m.topaid = :topaid";
		}
		valueMap.put( "aid", admin.get( "id" ) );
		valueMap.put( "aid2", admin.get( "id" ) );
		
		return getDefinedSQL( );
		
		
	}
	
	@Override
	public String getDefinedSQL( ) {
		String beginSQL = " and (m.adminid in( select id from dstzadmin where";
		String endSQL = " and aid = :aid ) or m.adminid = :aid2 )";
		return beginSQL +  super.getDefinedSQL( ) + endSQL ;
	}
	
	
	
}
